setwd("/Users/uirzhangqi/Box Sync/Working papers/Done/A granular theory of alliance and foreign aid allocation/Tables")
setwd("/Users/uirzhangqi/Library/CloudStorage/Box-Box/Working papers/Done/A granular theory of alliance and foreign aid allocation/Tables")
data1<-read.csv("/Users/uirzhangqi/Box Sync/Working papers/Done/A granular theory of alliance and foreign aid allocation/data/root data/US1.csv")
test1<-all1[all1$donor=="US"|all1$donor=="UK"|all1$donor=="France",]
all1<-read.csv("/Users/uirzhangqi/Box Sync/Working papers/Done/A granular theory of alliance and foreign aid allocation/data/root data/ALL1.csv")
all1<-read.csv("/Users/uirzhangqi/Library/CloudStorage/Box-Box/Working papers/Done/A granular theory of alliance and foreign aid allocation/data/root data/ALL1.csv")
data1<-read.csv("/Users/uirzhangqi/Library/CloudStorage/Box-Box/Working papers/Done/A granular theory of alliance and foreign aid allocation/data/root data/US1.csv")
##### create table 1
test1<-all1[all1$donor=="US"|all1$donor=="UK"|all1$donor=="France",]
test1$ln_pop<-log(test1$WB.pop)
vars<-c("WB.pop","rgdp","polity2","unsc","ln_gdp_pc","aid_average","soldiers_pc","colony","eu", "UN_voting", "distcap","unsc")
CreateTableOne(vars, strata = "dcaGeneralV1", data = test1)
library(tableone)
##### create table 1
test1<-all1[all1$donor=="US"|all1$donor=="UK"|all1$donor=="France",]
test1$ln_pop<-log(test1$WB.pop)
vars<-c("WB.pop","rgdp","polity2","unsc","ln_gdp_pc","aid_average","soldiers_pc","colony","eu", "UN_voting", "distcap","unsc")
CreateTableOne(vars, strata = "dcaGeneralV1", data = test1)
CreateTableOne(vars, data = test1)
head(test1)
CreateTableOne(vars, strata = "defense", data = test1)
head(test1)
vars<-c("ln_pop","rgdp","polity2","unsc","ln_gdp_pc","aid_average","soldiers_pc","colony","eu", "UN_voting", "distcap","unsc")
CreateTableOne(vars, data = test1)
CreateTableOne(vars, strata = "defense", data = test1)
CreateTableOne(vars, strata = "dcaGeneralV1", data = test1)
head(test1)
CreateTableOne(vars, data = test1)
vars<-c("ln_pop","rgdp","polity2","unsc","ln_gdp_pc","aid_average","soldiers_pc","mil_percent","colony","eu", "UN_voting", "distcap","unsc")
CreateTableOne(vars, data = test1)
summary(test1)
test1$mil_percent1 <- test1$mil_percent*100 #covert to percentage
vars<-c("ln_pop","rgdp","polity2","unsc","ln_gdp_pc","aid_average","soldiers_pc","mil_percent1","colony","eu", "UN_voting", "distcap","unsc")
CreateTableOne(vars, data = test1)
CreateTableOne(vars, strata = "defense", data = test1)
CreateTableOne(vars, strata = "dcaGeneralV1", data = test1)
m11<-felm(aid_average~defense*milex_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
data=all1[all1$donor=="US" ])
library(lfe)
library(gsynth)
m11<-felm(aid_average~defense*milex_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
data=all1[all1$donor=="US" ])
m11<-felm(aid_average~defense*milex_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
data=all1[all1$donor=="US" ])
m11<-felm(aid_average~defense*milex_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
data=all1[all1$donor=="US" ,])
m12<-felm(aid_average~defense*milex_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
data=all1[all1$donor=="UK",])
m13<-felm(aid_average~defense*milex_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
data=all1[all1$donor=="France" ])
m13<-felm(aid_average~defense*milex_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
data=all1[all1$donor=="France" ,])
#m14<-felm(aid_average~defense*milex_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
#data=all1[all1$donor=="Germany",])
m15<-felm(aid_average~defense*milper_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
data=all1[all1$donor=="US" ,])
m16<-felm(aid_average~defense*milper_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
data=all1[all1$donor=="UK",])
m17<-felm(aid_average~defense*milper_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
data=all1[all1$donor=="France" ,])
#m18<-felm(aid_average~defense*milper_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
#data=all1[all1$donor=="Germany",])
stargazer(m11,m12,m13,m15,m16,m17, no.space = TRUE, type="text")
library(stargazer)
stargazer(m11,m12,m13,m15,m16,m17, no.space = TRUE, type="text")
stargazer(m11,m12,m13,m14,m15,m16, no.space = TRUE, type="text")
m21<-felm(aid_average~dcaGeneralV1*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+pre_DCA5+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US",])
m22<-felm(aid_average~dcaGeneralV1*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+pre_DCA5+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK",])
m23<-felm(aid_average~dcaGeneralV1*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+pre_DCA5+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France",])
m24<-felm(aid_average~dcaGeneralV1*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+pre_DCA5+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US",])
m25<-felm(aid_average~dcaGeneralV1*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+pre_DCA5+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK",])
m26<-felm(aid_average~dcaGeneralV1*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+pre_DCA5+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France",])
stargazer(m21,m22,m23,m24,m25,m26, no.space = TRUE, type = "text")
m51<-felm(average_econ_lag~defense*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+UN_voting+eu+log_econ+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=data1)
m52<-felm(average_mil_lag~defense*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+UN_voting+eu+log_military_constant+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=data1)
m53<-felm(average_green_lag~defense*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+UN_voting+eu+greenbook_total+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=data1)
m54<-felm(average_econ_lag~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+UN_voting+eu+colony+distcap+log_econ+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=data1)
m55<-felm(average_mil_lag~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+UN_voting+eu+colony+distcap+log_military_constant+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=data1)
m56<-felm(average_green_lag~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+UN_voting+eu+colony+distcap+greenbook_total+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=data1)
stargazer(m51,m52,m53,m54,m55,m56, no.space = TRUE, type = "text")
m61<-felm(average_green_lag~defense*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+UN_voting+eu+greenbook_total+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=data1)
m62<-felm(average_green_lag~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+UN_voting+eu+colony+distcap+greenbook_total+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=data1)
m63<-felm(average_green_lag~dcaGeneralV1*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+UN_voting+eu+greenbook_total+pre_DCA5+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=data1)
m64<-felm(average_green_lag~dcaGeneralV1*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+UN_voting+eu+colony+distcap+greenbook_total+pre_DCA5+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=data1)
stargazer(m61,m62, m63, m64, no.space = TRUE)
m41<-felm(aid_average~defense*milex_norm+log(WB.pop)+distcap+polity2++ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |region+year|0|countryname,
data=all1[all1$donor=="US",])
m42<-felm(aid_average~defense*milex_norm+log(WB.pop)+distcap+polity2++ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |region+year|0|countryname,
data=all1[all1$donor=="UK",])
m43<-felm(aid_average~defense*milex_norm+log(WB.pop)+distcap+polity2++ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |region+year|0|countryname,
data=all1[all1$donor=="France",])
m44<-felm(aid_average~defense*milex_norm+log(WB.pop)+distcap+polity2++ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |region+year|0|countryname,
data=all1[all1$donor=="Germany",])
m45<-felm(aid_average~defense*milper_norm+log(WB.pop)+distcap+polity2++ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |region+year|0|countryname,
data=all1[all1$donor=="US",])
m46<-felm(aid_average~defense*milper_norm+log(WB.pop)+distcap+polity2++ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |region+year|0|countryname,
data=all1[all1$donor=="UK",])
m47<-felm(aid_average~defense*milper_norm+log(WB.pop)+distcap+polity2++ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |region+year|0|countryname,
data=all1[all1$donor=="France",])
m48<-felm(aid_average~defense*milper_norm+log(WB.pop)+distcap+polity2++ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |region+year|0|countryname,
data=all1[all1$donor=="Germany",])
stargazer(m41,m42,m43,m44,m45,m46,m47,m48, no.space = TRUE, type="text")
all1$yes_no<-NA
all1$yes_no[all1$aid_average>0]<-1
all1$yes_no[all1$aid_average==0]<-0
a31<-felm(yes_no~defense*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US",])
a32<-felm(yes_no~defense*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK",])
a33<-felm(yes_no~defense*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France",])
a34<-felm(yes_no~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US",])
a35<-felm(yes_no~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK",])
a36<-felm(yes_no~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France",])
a311<-felm(aid_average~defense*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US" &all1$aid_average>0,])
a321<-felm(aid_average~defense*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK"&all1$aid_average>0,])
a331<-felm(aid_average~defense*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France"&all1$aid_average>0,])
a341<-felm(aid_average~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US"&all1$aid_average>0,])
a351<-felm(aid_average~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK"&all1$aid_average>0,])
a361<-felm(aid_average~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France"&all1$aid_average>0,])
stargazer(a31,a311, a32,a321,a33,a331,a34,a341,a35,a351, a36, a361,no.space = TRUE, type="text")
stargazer(a31,a311, a32,a321,a33,a331,a34,a341,a35,a351, a36, a361,no.space = TRUE)
stargazer(a31,a311, a32,a321,a33,a331,a34,a341,a35,a351, a36, a361)
stargazer(a31,a311, a32,a321)
stargazer(a31,a311, a32,a321,a33,a331,a34)
stargazer(a31,a311, a32,a321,a33,a331,a34,a341,a35,a351, a36, a361)
stargazer(a31,a311, a32,a321,a33,a331,a34,a341,a35,a351, a36)
a361<-felm(aid_average~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France"&all1$aid_average>0,])
summary(a361)
stargazer(a31,a311, a32,a321,a33,a331,a34,a341,a35,a351, a36, a361, no.space = TRUE)
stargazer(a31,a311, a32,a321,a33,a331,a34,a341,a35,a351, a36, a361, no.space = TRUE)
stargazer(a31,a311, a32,a321,a33,a331,a34,a341,a35,a351, a36, no.space = TRUE, type="text")
stargazer(a31,a311, a32,a321,a33,a331,a34,a341,a35,a351, a361, no.space = TRUE, type="text")
stargazer(a31,a311, a32,a321,a33,a331,a34,a341,a35,a351, a36,a361, no.space = TRUE, type="text")
stargazer(a31,a311, a32,a321,a33,a331,a34,a341,a35,a351, a36,a361, type="text")
library(stargazer)
all1$yes_no <- NULL
all1$yes<-NA
all1$yes[all1$aid_average>0]<-1
all1$yes[all1$aid_average==0]<-0
#selection
a31<-felm(yes~defense*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US",])
a32<-felm(yes~defense*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK",])
a33<-felm(yes~defense*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France",])
a34<-felm(yes~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US",])
a35<-felm(yes~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK",])
a36<-felm(yes~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France",])
#allocation
a311<-felm(aid_average~defense*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US" &all1$aid_average>0,])
a321<-felm(aid_average~defense*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK"&all1$aid_average>0,])
a331<-felm(aid_average~defense*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France"&all1$aid_average>0,])
a341<-felm(aid_average~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US"&all1$aid_average>0,])
a351<-felm(aid_average~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK"&all1$aid_average>0,])
a361<-felm(aid_average~defense*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France"&all1$aid_average>0,])
stargazer(a31,a311, a32,a321,a33,a331,a34,a341,a35,a351, a36,a361, no.space = TRUE, type="text")
model_names <- c("m1", "m2""m3","m4","m5","m6","a1","a2","a3","a4","a5","a6")
model_names <- c("m1", "m2","m3","m4","m5","m6","a1","a2","a3","a4","a5","a6")
model_names <- c("m1", "m2","m3","m4","m5","m6","a1","a2","a3","a4","a5","a6")
stargazer(a31,a311, a32,a321,a33,a331,a34,a341,a35,a351, a36,a361, no.space = TRUE, type="text",covariate.labels = model_names)
stargazer(a31,a311, a32,a321,a33,a331,a34,a341,a35,a351, a36,a361, no.space = TRUE,covariate.labels = model_names)
stargazer(a31, a32,a33,a34,a35, a36, no.space = TRUE)
stargazer(a311,a321,a331,a341,a351, a361, no.space = TRUE)
stargazer(m411,m421,m431,m441,m451,m461, no.space = TRUE, type="text")
stargazer(m41, m42,m43,m44,m45, m46,no.space = TRUE, type="text")
a41<-felm(yes_no~dcaGeneralV1*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US",])
a41<-felm(yes~dcaGeneralV1*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US",])
a42<-felm(yes~dcaGeneralV1*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK",])
a43<-felm(yes~dcaGeneralV1*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France",])
a44<-felm(yes~dcaGeneralV1*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US",])
a45<-felm(yes~dcaGeneralV1*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK",])
a46<-felm(yes~dcaGeneralV1*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France",])
stargazer(a41, a42,a43,a44,a45, a46,no.space = TRUE, type="text")
stargazer(a41, a411,a42,a21,a43, a431,no.space = TRUE, type="text")
a411<-felm(aid_average~dcaGeneralV1*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US" &all1$aid_average>0,])
a421<-felm(aid_average~dcaGeneralV1*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK"&all1$aid_average>0,])
a431<-felm(aid_average~dcaGeneralV1*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France"&all1$aid_average>0,])
a441<-felm(aid_average~dcaGeneralV1*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US"&all1$aid_average>0,])
a451<-felm(aid_average~dcaGeneralV1*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK"&all1$aid_average>0,])
a461<-felm(aid_average~dcaGeneralV1*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France"&all1$aid_average>0,])
a41<-felm(yes~dcaGeneralV1*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US",])
a42<-felm(yes~dcaGeneralV1*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK",])
a43<-felm(yes~dcaGeneralV1*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France",])
a44<-felm(yes~dcaGeneralV1*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="US",])
a45<-felm(yes~dcaGeneralV1*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK",])
a46<-felm(yes~dcaGeneralV1*milex_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France",])
stargazer(a41, a411,a42,a21,a43, a431,no.space = TRUE, type="text")
a42<-felm(yes~dcaGeneralV1*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="UK",])
a43<-felm(yes~dcaGeneralV1*milper_norm+log(WB.pop)+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+log(export_to_donor+1)+log(import_from_donor+1) |countryname+year|0|countryname,
data=all1[all1$donor=="France",])
stargazer(a41, a411,a42,a421,a43, a431,no.space = TRUE, type="text")
stargazer(a44,a441,a45,a451,a46,a461, no.space = TRUE, type="text")
stargazer(a31,a311,a32,a321,a33, a331, no.space = TRUE)
stargazer(a34,a341,a35,a351,a36, a361, no.space = TRUE)
## Quick fix for stargazer <= 5.2.3 is.na() issue with long model names in R >= 4.2
# Unload stargazer if loaded
detach("package:stargazer",unload=T)
# Delete it
remove.packages("stargazer")
# Download the source
download.file("https://cran.r-project.org/src/contrib/stargazer_5.2.3.tar.gz", destfile = "stargazer_5.2.3.tar.gz")
# Unpack
untar("stargazer_5.2.3.tar.gz")
# Read the sourcefile with .inside.bracket fun
stargazer_src <- readLines("stargazer/R/stargazer-internal.R")
# Move the length check 5 lines up so it precedes is.na(.)
stargazer_src[1990] <- stargazer_src[1995]
stargazer_src[1995] <- ""
# Save back
writeLines(stargazer_src, con="stargazer/R/stargazer-internal.R")
# Compile and install the patched package
install.packages("stargazer", repos = NULL, type="source")
library(stargazer)
stargazer(a31,a311, a32,a321,a33,a331,a34,a341,a35,a351, a36,a361, no.space = TRUE, type="text")
stargazer(a41,a411, a42,a421,a43,a431,a44,a441,a45,a451, a46,a461, no.space = TRUE, type="text")
library(ggplot2)
library(reshape)
setwd("/Users/uirzhangqi/Library/CloudStorage/Box-Box/Working papers/Done/A granular theory of alliance and foreign aid allocation/graphs")
data<-read.csv("DAC_aid_complete.csv")
temp<-aggregate(oda_net_constant~donor,
data[data$donor !="Multilaterals, Total",], sum)
colnames(temp)[2]<-"total_aid"
aid_total<-aggregate(oda_net_constant~year,
data[data$donor !="Multilaterals, Total",], sum)
colnames(aid_total)[2]<-"total_aid"
aid_by_donor<-aggregate(oda_net_constant~year+donor,
data[data$donor !="Multilaterals, Total",], sum)
colnames(aid_by_donor)[3]<-"aid_by_donor"
aid<-merge(aid_total,aid_by_donor,
by = "year",
all = TRUE)
aid$aid_share<-100*aid$aid_by_donor/aid$total_aid
aid1<-aid[aid$donor=="United States"|
aid$donor=="Germany"|
aid$donor=="Japan"|
aid$donor=="France"|
aid$donor=="United Kingdom",]
p <- ggplot(data=aid1[aid1$year<2018,], aes(x=year, y=aid_share, fill=donor)) +
geom_line(aes(color=donor))+
xlab("year")+
ylab("share of aid (%)")+
ggtitle("Figure 1: Share of bilateral aid of top 5 donor")+
geom_area( position = 'stack')+
scale_fill_manual(values = c("palegoldenrod","wheat3","palegreen3","paleturquoise3","skyblue3"))
p
setwd("/Users/uirzhangqi/Desktop/Replication material/Datasets")
data1<-read.csv("main_US_greenbook.csv")
all1<-read.csv("main_all.csv")
m11<-felm(aid_average~defense*milex_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
data=all1[all1$donor=="US" ,])
m12<-felm(aid_average~defense*milex_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
data=all1[all1$donor=="UK",])
m13<-felm(aid_average~defense*milex_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
data=all1[all1$donor=="France" ,])
m14<-felm(aid_average~defense*milper_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
data=all1[all1$donor=="US" ,])
m15<-felm(aid_average~defense*milper_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
data=all1[all1$donor=="UK",])
m16<-felm(aid_average~defense*milper_norm+log(WB.pop)+distcap+polity2+ln_gdp_pc+unsc+aid_log+UN_voting+eu+pre_alliance5+log(export_to_donor+1)+log(import_from_donor+1) |ID+year|0|countryname,
data=all1[all1$donor=="France" ,])
stargazer(m11,m12,m13,m14,m15,m16, no.space = TRUE)
g1<-ggplot(data=all1[all1$donor!="Japan" & all1$donor !="Germany",], aes(x=year, y=ln_milex_weighted*10, group=donor)) +
geom_line(aes(color=donor))+
xlab("year")+
ylab("Military spending (share of GDP)")+
ylim(0,0.15)+
ggtitle("Military spending indicator")+
theme(legend.position = "none")
g2<-ggplot(data=all1[all1$donor!="Japan"& all1$donor !="Germany",,], aes(x=year, y=ln_milper_weighted, group=donor)) +
geom_line(aes(color=donor))+
xlab("year")+
ylab("Military personnel (thousands)")+
ylim(10,30)+
ggtitle("Military personnel indicator")+
theme(legend.position = c(0.85,0.8))
figure <- ggarrange(g1, g2,
ncol = 2, nrow = 1)
library(ggpubr)
library(ggplot2)
g1<-ggplot(data=all1[all1$donor!="Japan" & all1$donor !="Germany",], aes(x=year, y=ln_milex_weighted*10, group=donor)) +
geom_line(aes(color=donor))+
xlab("year")+
ylab("Military spending (share of GDP)")+
ylim(0,0.15)+
ggtitle("Military spending indicator")+
theme(legend.position = "none")
g2<-ggplot(data=all1[all1$donor!="Japan"& all1$donor !="Germany",,], aes(x=year, y=ln_milper_weighted, group=donor)) +
geom_line(aes(color=donor))+
xlab("year")+
ylab("Military personnel (thousands)")+
ylim(10,30)+
ggtitle("Military personnel indicator")+
theme(legend.position = c(0.85,0.8))
figure <- ggarrange(g1, g2,
ncol = 2, nrow = 1)
options(repr.plot.width=15, repr.plot.height=8)
annotate_figure(figure,
top = text_grob("Figure 2: The security environment by donor", color = "black",  size = 16, x=0.5),
)
